﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using KinectTD.State_Management;
using System.IO;
using KinectTD.Game_Management;
namespace KinectTD
{
    public static class Engine
    {

        private static ScreenStack stack;
        public static Player gamePlayer;
        public const float CLICK_TIME_OUT = 1000;

        public static ScreenStack GameStack
        {
            get { return stack; }
            set { stack = value; }
        }

        public static float GAME_SPEED = 1;


        private static SpriteFont utilFont;

        public static SpriteFont UtilFont
        {
            get { return utilFont; }
            set { utilFont = value; }
        }

        private static Texture2D testTexture;
        /// <summary>
        /// A texture used for testing something graphically (avoid using for actual game play, the static texture in the Engine class will perform slower than one loaded on a per-screen basis)
        /// </summary>
        public static Texture2D TestTexture
        {
            get { return testTexture; }
            set { testTexture = value; }
        }

        private static Texture2D damageTexture;

        public static Texture2D DamageTexture
        {
            get { return damageTexture; }
            set { damageTexture = value; }
        }

        private static Texture2D rangeTexture;

        public static Texture2D RangeTexture
        {
            get { return rangeTexture; }
            set { rangeTexture = value; }
        }

        private static Texture2D speedTexture;

        public static Texture2D SpeedTexture
        {
            get { return speedTexture; }
            set { speedTexture = value; }
        }

        public static bool CheckCollision(Vector2 originA, Vector2 originB, float radiusA, float radiusB)
        {
            Vector2 pDiff = originA - originB;
            float distance = pDiff.Length();
            return (distance < radiusA + radiusB);
        }

        /// <summary>
        /// Used to measure the length of strings
        /// </summary>
        /// <param name="text">The string to measure</param>
        /// <param name="measuringFont">The font used to measure the string</param>
        /// <returns></returns>
        public static Vector2 StringLength(string text, SpriteFont measuringFont)
        {
            return measuringFont.MeasureString(text);
        }

        private static Viewport gameViewport;

        public static Viewport GameViewport
        {
            get { return gameViewport; }
            set { gameViewport = value; }
        }
        private static MenuScreen menu;
        public static MenuScreen MainMenu
        {
            get { return menu; }
            set { menu = value; }
        }

        /// <summary>
        /// Returns all the asset names in a specified directory
        /// </summary>
        /// <param name="path">The path where the assets are held</param>
        /// <returns>An array of all the assets in that directory(not type dependent)</returns>
        public static string[] assetNames(string path)
        {
            string[] assets = Directory.GetFiles(path);
            for (int i = 0; i < assets.Length; ++i)
            {
                assets[i] = Path.GetFileNameWithoutExtension(assets[i]);
            }
            return assets;

        }

    }
}
